package com.buddies.lottery.ui.pay.record.select;

import com.buddies.lottery.base.list.BaseListPresenter;
import com.buddies.lottery.data.BaseObserver;
import com.buddies.lottery.data.DataManager;
import com.buddies.lottery.data.bean.PayType;
import com.buddies.lottery.data.result.PageResult;

import java.util.Map;

public class PayTypeSelectPresenter extends BaseListPresenter<PayTypeSelectContract.View> implements PayTypeSelectContract.Presenter {

    public PayTypeSelectPresenter(PayTypeSelectContract.View view) {
        super(view);
    }

    @Override
    public PayTypeSelectContract.View getView() {
        return ((PayTypeSelectContract.View) mView);
    }

    @Override
    public void onLoadData(Map<String, Object> params, int page) {
        addSubscription(DataManager.getInstance().getUserRepo().getPayTypeList(), new BaseObserver<PageResult<PayType>>() {
            @Override
            public void onNext(PageResult<PayType> response) {
                getView().onDataLoaded(response);
            }

            @Override
            public void onError(Throwable e) {
                getView().onError(e);
            }
        });
    }

}
